import { WorkshiftService } from './../service/workshiftService';
import { Response, ServiceConfig, route, Guid, uniqueArray, intersectionArray } from '../common';
import { RequestLog } from '../common/http/router/routeDecorators';
import * as Koa from "koa";


export class WorkshiftController {
    private workshiftSvr: WorkshiftService;
    constructor() {
        this.workshiftSvr = ServiceConfig.Current.GetService<WorkshiftService>('workshiftService');
    }

    @route({ method: "post", path: "/api/workshifts/create" })
    @RequestLog()
    async create(ctx: Koa.Context, next) {
        let user = ctx.request.body.user;
        let closeTime = ctx.request.body.closeTime;
        let currentWorkshift = ctx.request.body.workshift;
        let data = await this.workshiftSvr.generateWorkshiftInfo(closeTime, user, currentWorkshift);
        ctx.response.body = Response.ok("success", data);
        await next();
    }


}